package a;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;


public class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();//桌子个数
        int m = scanner.nextInt();//客人批数
        scanner.nextLine();
        int[] a = new int[n];//每张桌子容量
        for (int i = 0; i < n; i++) {
            a[i]= scanner.nextInt();
            System.out.println(a[i]);
        }
        int[][] b=new int[m][2];//每批人数和人均消费
        for (int i = 0; i < m; i++) {
            b[i][0]=scanner.nextInt();
            b[i][1]=scanner.nextInt();
            scanner.nextLine();
        }
        Arrays.sort(b, Comparator.comparingInt(o -> o[0]));
        for (int i = 0; i < m; i++) {

        }
    }
}